<template>
	<view class="container-withdrawal" style="background: #F5F9FF">
		<!-- <view class="bgc">
			<image src="@/static/imgbgc.png" mode=""></image>
		</view> -->
		<!-- <view class="header" style="color: #fff;">
			<u-cell :title="title" value="" @click="handleSelect">
				<view class="" slot="icon" style="width: 70rpx;height: 70rpx;">
					<image src="@/static/user/icon.png" mode=""></image>
				</view>
				<view slot="title" class="flex">
					<text class="u-cell-text" style="margin-right: 10rpx;font-weight: 600;">单元格</text>
					<u-icon name="arrow-down" color=""></u-icon>
				</view>
			</u-cell>
		</view> -->
		<view class="app">
			<view class="top-box flex-between">
				<view class="title">
					{{$t('home.name15')}}
				</view>
				<!-- <view class="rule" @click="$fun.jump(`/pageB/noticeList/noticeInfo?id=19&type=20&name=提现规则`)">
					积分规则
				</view> -->
			</view>
			<!-- 提现记录 -->
			<view class="records">
				<scroll-view scroll-y="true" class="content" @scrolltolower="scrolltolower">
					<view class="item" v-for="item in marthlist">
						<view class="flex-between">
							<text>{{item.memo || item.name || item.wallet_name}}</text>
							<text class="price">{{item.money}}</text>
						</view>
						<view class="createTime">
							{{item.createtime }}
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<u-datetime-picker :show="show" v-model="title" mode="year-month" @close="show = false"
			@cancel="show = false"></u-datetime-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showPwd: false,
				money: '',
				list: [],
				bankList: [],
				bid: '',
				id: '',
				titleName: '', //标题
				placeholder: '',
				active: "`",
				balance: '==',
				balance1: '==',
				withdrawal_type: 0,
				isChecked: false,
				btnloading: false,
				marthlist: [],
				page: 1,
				limit: 20,
				title: '全部',
				show: false,
				type:1

			}
		},
		// onNavigationBarButtonTap(e) {
		// 	this.$fun.jump(`/pages/user/wallet/walletdetail?id=${this.id}`)
		// },
		onLoad(options) {
			this.id = options.id
			this.titleName = options.name
			this.type = options.type
			// this.$fun.ajax.post('config/recharge', {
			// 	id: options.id
			// }).then(res => {
			// 	this.balance = res.data.money
			// })
			uni.setNavigationBarTitle({
				title:options.name
			})
			this.getList()
			
		},
		computed: {
			// openExamine() {
			// 	return this.$store.state.openExamine;
			// }
		},
		watch: {
			money(val) {
				if (val) {
					this.money1 = ''
				}
			}
		},
		methods: {
			handleSelect() {
				this.show = true
			},
			scrolltolower(e) {
				this.getList()
			},
			async getList() {
				let res
				if (this.id) {
					 res = await this.$fun.ajax.post('user/balancelist', {
						id: this.id,
						page: this.page,
						limit: this.limit
					})
				}
				// 1充值 2 提现
				if(this.type == 1){
					 res = await this.$fun.ajax.post('user/rechargeList', {
						page: this.page,
						limit: this.limit
					})
				}
				if(this.type == 2){
					 res = await this.$fun.ajax.post('user/withdrawalList', {
						page: this.page,
						limit: this.limit
					})
				}
				
				if (res.code == 1 && res.data.length > 0) {
					if (this.page == 1) {
						this.marthlist = []
					}
					this.marthlist.push(...res.data)
					this.page++
				} else {
					if (this.page != 1) {
						this.$fun.msg(this.$t('equipment.name11'))
					}
				}
			},
			onChange(item, index) {
				// //console.log(e)
				this.active = index;
				this.bid = item.id;
			},
			configBank(e) {
				this.bid = this.bankList[e.index].id
			},
			changePwdState() {
				this.showPwd = !this.showPwd;
			}
		},
		onNavigationBarButtonTap(e) {
			const index = e.index;
			// #ifdef APP-PLUS
			const pages = getCurrentPages();
			const page = pages[pages.length - 1];
			const currentWebview = page.$getAppWebview();
			currentWebview.hideTitleNViewButtonRedDot({
				index
			});
			// #endif
			uni.navigateTo({
				url: `./withdrawList?id=${this.id}&name=${this.titleName}`
			})
		}

	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;
	}

	.container-withdrawal {
		padding-top: 20rpx;
		height: 100%;
		// position: relative;

		// .bgc {
		// 	height: 100%;
		// }

		.header {
			// position: absolute;
			// top: 30rpx;
			// left: 30rpx;
			// right: 30rpx;
			background-color: #fff;
			border-radius: 20rpx;
			margin: 0 30rpx 30rpx;
		}

		.records {
			margin: 20rpx 0;
			height: 100%;

			.header {
				.lt {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #232323;
					border-left: 5rpx solid #1e84f1;
					padding-left: 10rpx;
				}

				.rt {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
				}
			}

			.content {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #232323;
				line-height: 28rpx;
				height: 85%;

				.item {
					border-bottom: 1rpx solid #dedede;
					padding: 15rpx 0;
				}

				.price {
					font-family: DIN, DIN;
					font-weight: bold;
					font-size: 24rpx;
					color: #232323;
					line-height: 40rpx;
				}

				.createTime {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					line-height: 32rpx;
				}
			}
		}
	}

	.app {
		position: absolute;
		top: 50rpx;
		left: 30rpx;
		right: 30rpx;
		background-color: #fff;
		padding: 10rpx 30rpx 30rpx;
		border-radius: 20rpx;
		height: 80%;

		.add-btn {
			margin: 0 30rpx;
		}

		// padding: 20rpx;
		.top-box {
			color: #232323;
			padding: 20rpx 0;

			.title {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #232323;
				line-height: 38rpx;
			}

			.rule {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #848484;
				text-align: end;
			}


		}

		/* 头部 */
		.top {
			display: flex;
			justify-content: space-between;

			.left {
				// margin-top: 40rpx;

				.title {
					font-size: 24rpx;
					color: #232323;
				}

				.num {
					font-size: 48rpx;
					color: #232323;
					margin-top: 30rpx;
					font-weight: bold;
				}

				.jyjl {
					font-size: 24rpx;
					color: #dd1021;
					margin-top: 50rpx;
				}
			}

			.rightimg {
				width: 233rpx;
				height: 240rpx;
				margin-right: 50rpx;
			}
		}

		/* 内容区 */
		.conter {
			.title {
				color: #666;
				margin-top: 50rpx;
				font-size: 30rpx;
			}

			.cent {
				margin-top: 25rpx;
				overflow: hidden;

				.list {
					width: 200rpx;
					height: 120rpx;
					border: 1rpx solid #e8e8e8;
					float: left;
					margin-right: 39rpx;
					margin-bottom: 45rpx;
					position: relative;
					text-align: center;
					line-height: 120rpx;
					border-radius: 15rpx;

					&:nth-child(3n) {
						margin-right: 0;
					}

					input {
						height: 50rpx;
						margin-left: 10rpx;
						margin-top: 35rpx;
					}

					.van-cell {
						padding: 0;
						width: 180rpx;
					}

					image {
						width: 40rpx;
						height: 37rpx;
						position: absolute;
						bottom: 0;
						right: 0;
						display: none;
					}

					&.active {
						color: #dd1021;
						border: 1rpx solid #dd1021;

						image {
							display: block;
						}
					}
				}
			}
		}

		.bottom {
			width: 690rpx;

			.text {
				margin-bottom: 30rpx;
				display: flex;
				font-size: 24rpx;
				line-height: 40rpx;

				.van-checkbox {}

				navigator {
					color: #dd1021;
				}
			}

			button {
				width: 690rpx;
				height: 78rpx;
				line-height: 78rpx;
				background: #dd1021;
				color: #fff;
				border-radius: 78rpx;
				font-weight: 500;
				margin: 0;
				padding: 0;
			}
		}
	}

	/* 提现 */
	.member {
		.conter {
			width: 694rpx;
			height: 175rpx;
			background: #f3f3f3;
			margin: 20rpx auto;
			border-radius: 10rpx;
			display: flex;

			&.active {
				border: 1px solid #1E84F1;
			}

			.left {
				margin-left: 20rpx;
				margin-top: 25rpx;
				width: 425rpx;

				.top {
					width: 82rpx;
					height: 30rpx;
					font-size: 18rpx;
					color: #fff;
					background: linear-gradient(to right, #242a42, #474e61);
					border-radius: 30rpx;

					image {
						width: 20rpx;
						height: 17rpx;
						margin-left: 10rpx;
						margin-right: 5rpx
					}
				}

				.cent {
					color: #333;
					font-size: 32rpx;
					margin-top: 10rpx;

					text {
						color: #1E84F1;
					}
				}

				.name {
					margin-top: 15rpx;
					font-size: 24rpx;
					color: #666;
				}
			}

			.data {
				margin-top: 65rpx;
				color: #000;
				font-size: 28rpx;
				margin-right: 20rpx;
			}

			.van-checkbox {
				margin-top: 65rpx;
			}
		}
	}



	.nocell {
		border-bottom: none !important;
	}

	.cell1 {
		min-height: 110rpx;
		margin: 0 40rpx;
		padding: 10rpx 0;
		border-bottom: 1px solid rgb(236, 236, 236);

		.onchargecost {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #232323;
			line-height: 100rpx;
		}
	}

	.cell {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		margin: 0 40rpx;
		border-bottom: 1px solid rgb(236, 236, 236);

		&:first-child {
			margin-bottom: 10rpx;
		}

		&:after {
			left: 40rpx;
			right: 40rpx;
			border-color: #d8d8d8;
		}

		.tit {
			font-size: 30rpx;
			color: #333;
		}

		.avatar-wrap {
			width: 120rpx;
			height: 120rpx;
			position: relative;
			border-radius: 100rpx;
			overflow: hidden;

			.avatar {
				width: 100%;
				height: 100%;
				border-radius: 100rpx;
			}

			.progress {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				width: 100rpx;
				height: 100rpx;
				box-shadow: rgba(0, 0, 0, .6) 0px 0px 0px 2005px;
				border-radius: 100rpx;
				transition: .5s;
				opacity: 0;

				&.no-transtion {
					transition: 0s;
				}

				&.show {
					opacity: 1;
				}
			}
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}

		switch {
			margin: 0;
			transform: scale(0.8) translateX(10rpx);
			transform-origin: center right;
		}

		.tip {
			margin-left: 20rpx;
			font-size: 28rpx;
			color: #999;
		}

		.checkbox {
			padding: 12rpx 0 12rpx 40rpx;
			font-size: 28rpx;
			color: #333;

			.mix-icon {
				margin-right: 12rpx;
				font-size: 36rpx;
				color: #ccc;
			}

			.icon-xuanzhong {
				color: $base-color;
			}
		}
	}
</style>